仿照SQL取出flag==true
的物件
success: function(res) {
console.log(res);
const showHospital = res.filter(function(element) {
return element.flag == true
})
}
完整版
function his_data() {
$.ajax({
url: '<?php echo site_url('HIS/GetHIS'); ?>',
method: 'get',
dataType: 'json',
success: function(res) {
console.log(res);
const showHospital = res.filter(function(element) {
return element.flag == true
})
console.log(showHospital)
renderHeaderRow(showHospital); //渲染標題列的內容(2間醫院)
renderRowOptions(showHospital); //渲染標題列的下拉式選單(之後醫院會增加)
changeHospital(showHospital); //標題列下拉之後改變醫院的標題
Object.keys(showHospital[0]).forEach(element => {
if (element != 'id' && element != 'attribute' && element != 'title')
renderFixedItems(showHospital, element);
});
renderColValues(showHospital);
// addItem(res); //增加項目欄位
// changeItem(res); //依據項目欄位改變內容
},
error: function(err) {
console.log(err)
},
});
}
```